<html>
<head>
    <meta charset="UTF-8">
    <title>添加</title>
</head>
<link rel="stylesheet" href="/static/layui/css/layui.css" />
<body>
<form class="layui-form" id="user-add"  action="" lay-filter="add">
    <div class="layui-form-item" hidden="hidden">
        <label class="layui-form-label">日期：</label>
        <div class="layui-input-inline layui-col-md4">
            <input type="text" name="ctime" id="ctime" required  lay-verify="required" placeholder="请输入日期" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">名称：</label>
        <div class="layui-input-inline layui-col-md4">
            <input type="text" name="cname" id="cname"  required  lay-verify="required" placeholder="请输入名称" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo">提交</button>
            <!--            <button type="reset" class="layui-btn layui-btn-primary">重置</button>-->
        </div>
    </div>
</form>
</body>

<script src="/static/js/jquery-3.3.1.js"></script>
<script src="/static/layui/layui.js"></script>
<script>

    //Demo
    layui.use(['form','laydate'], function(){
        var form = layui.form;
        var laydate = layui.laydate;
        laydate.render({
            elem:'#ctime',
            value:new Date(),
            // type:'date'
        });
        //监听提交
        form.on('submit(formDemo)', function(data){
            var data1 = form.val("add");
            $.ajax({
                url:'/addGeneResult',
                type:"get",
                dataType:"json",
                data:data1,
                success:function (da) {
                    if (da.code == 200) {
                        layer.alert("添加成功！", function () {
                            // window.parent.location.reload();//刷新父页面
                            // parent.layer.close(layer.index);//关闭弹出层
                            parent.layer.closeAll();
                        });
                    } else {
                        layer.msg("添加失败！");
                    }
                }
            });
            return false;
        });

    });
</script>
</html>